<template name="theme">
  <div class="view">
    <h2 class="title">主题精选</h2>
    <ul class="tabs">
      <li
        v-for="(item,i) in tabsList"
        :key="i"
        :class="{'is_this' : i == count , 'afRight':true}"
        @mousemove="onTabs(i)"
      >{{item}}</li>
    </ul>
    <template v-for="(item) in themeContent">
      <ul class="contentGroup" :key="item.id" v-if="count == item.id">
        <li
          class="quarterContent"
          v-for="(items) in item.contentList"
          :key="items.content_id"
          :style="{backgroundImage: 'url(' +items.img+ ')'}"
        >
          <span style="padding: 0 0 20px 20px;">{{items.place}}</span>
        </li>
      </ul>
    </template>
  </div>
</template>

<script>
import {mapState} from 'vuex'
export default {
  name: "theme",
  data() {
    return {
      tabsList: [],
      count: 0,
    };
  },
  computed:{
    ...mapState(['themeContent'])
  },
  methods: {
    getData() {
      let tabs = ["全年适宜", "季节", "出行方式", "节假日"];
      this.tabsList = tabs;
      this.$store.dispatch('reqThemeContent')
    },
    onTabs(i) {
      this.count = i;
    }
  },
  mounted() {
    this.getData();
  }
};
</script>

<style lang="stylus" scoped>
.view {
  width: 1000px;
  margin: auto;
  padding:40px 0;

  .title {
    text-align: center;
    font-weight: normal;
    margin: 25px;
  }

  .tabs {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
    cursor: pointer;

    .is_this {
      color: orange;
      position: relative;

      &:before {
        content: '';
        width: 100%;
        height: 3px;
        background-color: orange;
        position: absolute;
        bottom: -12px;
      }
    }

    .afRight {
      position: relative;
      margin: 0 30px;

      &:after {
        content: '';
        width: 1px;
        height: 16px;
        background-color: #eee;
        position: absolute;
        right: -27px;
        top: 3px;
      }

      &:last-child {
        &:after {
          content: '';
          width: 0;
          height: 0;
        }
      }
    }
  }

  .contentGroup {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    height: 720px;
  }

  .quarterContent {
    width: 238px;
    height: 220px;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    display: flex;
    align-items: flex-end;
    font-size: 20px;
    color: #ffffff;
  }
}
</style>